﻿using Aop.Api;
using Aop.Api.Domain;
using Aop.Api.Request;
using Aop.Api.Response;
using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;

namespace BLL.paymentmanager
{
    public class PaymentService : System.Web.UI.Page
    {
        public void AliPay(HttpResponse resp,DefaultAopClient client, ps_users ps_Users, AlipayTradePagePayModel model, string username, string amount)
        {
            AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
            // 设置同步回调地址
            request.SetReturnUrl("http://localhost:22865/main.aspx");
            // 设置异步通知接收地址
            request.SetNotifyUrl("");
            // 将业务model载入到request
            request.SetBizModel(model);

            AlipayTradePagePayResponse response = null;
            try
            {
                response = client.pageExecute(request, null, "post");

                resp.Write(response.Body);
                int id = int.Parse(username);
                int pointCount = int.Parse(amount);
                ps_Users.CheakPoint(id, pointCount);
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
    }
}
